/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
 *
 * Filename:
 * ---------
 *   ResCompressUtil.c
 *
 * Project:
 * --------
 *   MAUI
 *
 * Description:
 * ------------
 *   helpers for resource compression.
 *
 * 
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!

 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

#include "MMI_features.h"
#include "ResCompressConfig.h"
#if defined(__MMI_RESOURCE_STR_LZMA_COMPRESS__) || defined(__MMI_RESOURCE_IMAGE_GROUP_COMPRESS__)

#if (!defined (__MTK_TARGET__))
    #define __align(x)
#endif

#include "lzmadec.h"
#include "simple_memory_manager.h"

#include "CompressResUtil.h"

#include "CustDataRes.h"
#include "CustDataProts.h"
#include "MMIDataType.h"
#include "kal_general_types.h"
#include "kal_public_api.h"
#include "DebugInitDef_Int.h"
#include "GlobalConstants.h"
#include "MMI_fw_trc.h"
#include "kal_trace.h"

#if defined(__MMI_RESOURCE_IMAGE_GROUP_COMPRESS__) || defined(__MMI_FONT_GROUP_COMPRESSION__)
// Build-in buffer, only enabled with image compression, and share with Font decompress
kal_uint32 mmi_res_decomp_static_buff_pool[RESORCE_LZMA_DECOMPRESS_WORKING_BUFFER_SIZE>>2];
#endif //__MMI_RESOURCE_IMAGE_GROUP_COMPRESS__

static STSMM res_lzma_decompress_smm;

static void* mmi_res_lzma_alloc(void* mem_ptr, kal_uint32 mem_size);
static void mmi_res_lzma_free(void* mem_ptr, void* mem_address);

static ISzAlloc mmi_res_lzma_decomp_Alloc = { mmi_res_lzma_alloc, mmi_res_lzma_free };

static void* mmi_res_lzma_alloc(void* mem_ptr, kal_uint32 mem_size)
{
    return smmMallocAligned(&res_lzma_decompress_smm, mem_size, 4);
}

static void mmi_res_lzma_free(void* mem_ptr, void* mem_address)
{
    // Res util will reset the entire buffer every time it decompresses the resource
    // So we do nothing here
}

#ifdef __MMI_RESOURCE_IMAGE_GROUP_COMPRESS__
S32 mmi_res_lzma_decompress_static_buffer(U8 *dest, U32 destLen, const U8 *source, U32 sourceLen)
{
    return mmi_res_lzma_decompress(dest, destLen, source, sourceLen, mmi_res_decomp_static_buff_pool);
}
#endif // __MMI_RESOURCE_IMAGE_GROUP_COMPRESS__

S32 mmi_res_lzma_decompress(U8 *dest, U32 destLen, const U8 *source, U32 sourceLen, void* mmi_res_decomp_buff_pool)
{
    S32 ret;
    U32 decpz_data_size = destLen;
    U32 source_size = sourceLen-13;
    ELzmaStatus status;
    smmInit(&res_lzma_decompress_smm, mmi_res_decomp_buff_pool, RESORCE_LZMA_DECOMPRESS_WORKING_BUFFER_SIZE);

    ret = LzmaDecode((Byte*)dest, &decpz_data_size, ((const Byte*)source)+13, &source_size, 
        (const Byte*)source, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, 
        &mmi_res_lzma_decomp_Alloc);
    if(SZ_OK == ret){
        ASSERT(decpz_data_size == destLen);
        return 0;
    }else{
        return -1;
    }
}

#ifdef __MMI_RESOURCE_UT_UNCOMPRESSED_IMAGE_SUPPORT__
// ------------------------------------- Unit Test Start---------------------------------------------

__align(4) U8 lzma_test_data_decompressed_buffer[1499];

__align(4) const U8 lzma_test_data_compressed[] = { 
    0x05, 0xD7, 0x02, 0x5C, 
    0x5C, 0x00, 0x00, 0x40, 0x00, 0xD7, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x52, 0x0A, 0xDF, 0x98, 0x1C, 0x57, 0x56, 0x37, 0xDC, 0x32, 0x82, 0xEC, 0x7D, 0x2A, 0x5E, 0xE9, 
    0x21, 0x00, 0xCA, 0x3A, 0x8E, 0x5F, 0x69, 0x79, 0xE4, 0xF1, 0xF2, 0x62, 0x29, 0xB3, 0xEC, 0xA1, 
    0x82, 0xDE, 0xB8, 0x23, 0x65, 0xFB, 0xE0, 0xBC, 0x44, 0x83, 0x0B, 0x9B, 0xB7, 0xF3, 0x60, 0x8F, 
    0x58, 0xA9, 0x57, 0x19, 0xB6, 0x25, 0x5B, 0x78, 0x33, 0xCF, 0x20, 0xF1, 0xAF, 0xFC, 0x2C, 0xCC, 
    0x2E, 0xD9, 0xFE, 0x29, 0xF9, 0xCC, 0xF0, 0xFD, 0x18, 0x4A, 0xFA, 0x30, 0x6E, 0x4E, 0x4D, 0x3C, 
    0xE0, 0x6D, 0xF9, 0xB9, 0x91, 0x81, 0x45, 0xB4, 0x8C, 0xB3, 0xF0, 0xDA, 0x41, 0x6F, 0xB1, 0x0E, 
    0x1C, 0xF7, 0x05, 0x10, 0x17, 0x9B, 0xE7, 0x39, 0xC8, 0x3E, 0x05, 0x25, 0x33, 0xAD, 0xD1, 0xAC, 
    0xA7, 0x79, 0xB9, 0xDA, 0xA2, 0xCB, 0xE9, 0x0A, 0x0F, 0x70, 0x9C, 0x21, 0xD7, 0x99, 0xE2, 0x7B, 
    0xB2, 0x27, 0xA7, 0x26, 0x1B, 0x81, 0x2C, 0xCA, 0xD7, 0x10, 0xF4, 0xF5, 0xC1, 0x39, 0x0A, 0xC5, 
    0x54, 0x82, 0x20, 0x05, 0x04, 0x3B, 0x61, 0x21, 0x41, 0x6A, 0x9F, 0x46, 0xDB, 0xB1, 0x60, 0x85, 
    0xC0, 0x2C, 0x0C, 0x80, 0x7A, 0xB6, 0x1B, 0x11, 0x04, 0x5C, 0x7A, 0x4E, 0x3C, 0xE4, 0x7D, 0x63, 
    0xF4, 0x6F, 0x37, 0x79, 0x22, 0x07, 0xBC, 0xA9, 0x3B, 0xCF, 0x2E, 0x32, 0xC5, 0x04, 0xC6, 0x6C, 
    0x59, 0x73, 0xFA, 0x60, 0xF4, 0xF3, 0xD3, 0x8D, 0xA2, 0xD3, 0x02, 0x39, 0x44, 0xD7, 0x9A, 0x9B, 
    0x1D, 0x87, 0xF3, 0x2D, 0x16, 0xB4, 0x17, 0x04, 0x19, 0xBC, 0x9A, 0xEF, 0xD1, 0x89, 0xA8, 0xDE, 
    0xEF, 0x96, 0xF7, 0xB7, 0xC1, 0x53, 0x05, 0xB3, 0xB4, 0x85, 0xEA, 0xB7, 0x68, 0x2D, 0xD2, 0x3D, 
    0x94, 0x6E, 0xAA, 0x69, 0x0D, 0x49, 0xC0, 0x0F, 0x99, 0x90, 0xEC, 0xA3, 0xE9, 0x9A, 0xDE, 0x60, 
    0x52, 0x77, 0x6D, 0xA1, 0x5F, 0x83, 0xFC, 0x10, 0x3B, 0xF0, 0x40, 0xEE, 0x44, 0xD8, 0x4B, 0x2E, 
    0xE0, 0x6E, 0xF6, 0xBB, 0x65, 0x94, 0xE7, 0x2E, 0x2A, 0x9E, 0x68, 0x52, 0x2F, 0x03, 0x3A, 0xA0, 
    0xE2, 0x5D, 0x4C, 0x95, 0x36, 0xDA, 0x63, 0xF9, 0xF9, 0x59, 0x58, 0x43, 0x73, 0x45, 0xA5, 0x06, 
    0xF7, 0xB0, 0xC9, 0x6E, 0x36, 0x20, 0xD9, 0xD2, 0x89, 0x53, 0x01, 0xFF, 0xE2, 0xF6, 0x51, 0x53, 
    0x3F, 0x72, 0xF5, 0xF2, 0x75, 0xE8, 0xC7, 0xD1, 0xAC, 0x86, 0x58, 0xD1, 0xB2, 0xB8, 0x07, 0x48, 
    0xB4, 0x0A, 0xB6, 0x05, 0x6E, 0xE4, 0x68, 0xE7, 0x6F, 0x72, 0x63, 0x17, 0x36, 0x46, 0xAA, 0xB0, 
    0x7A, 0xCA, 0x90, 0xA0, 0x68, 0x02, 0x62, 0x0F, 0xD6, 0xC5, 0x61, 0x2C, 0x1A, 0x5A, 0xD5, 0x73, 
    0x62, 0xF8, 0x45, 0xC7, 0x46, 0xC3, 0x15, 0xDF, 0x43, 0x01, 0xAC, 0x90, 0xE3, 0x5A, 0xE3, 0x14, 
    0x48, 0xBF, 0x73, 0x0D, 0x61, 0x90, 0x59, 0x88, 0xEF, 0xDC, 0x7C, 0xC4, 0x62, 0x7A, 0x21, 0xB7, 
    0x5B, 0xE2, 0x98, 0xA1, 0x24, 0x5B, 0xA1, 0x7D, 0x13, 0x19, 0xB7, 0xBD, 0x06, 0xCA, 0xCF, 0xC7, 
    0x2B, 0x14, 0x5C, 0xDB, 0xDA, 0xC1, 0x2E, 0x36, 0x0C, 0xE7, 0xA8, 0x82, 0xF4, 0x4F, 0x62, 0xE4, 
    0xC8, 0xF7, 0xCC, 0xB0, 0xB4, 0x26, 0x52, 0xC6, 0x85, 0xA8, 0x02, 0xCB, 0x14, 0x70, 0xCF, 0xB3, 
    0x08, 0xA1, 0xC1, 0x3C, 0x68, 0x34, 0x16, 0x40, 0xFB, 0x9D, 0x57, 0x5A, 0x7E, 0x20, 0x1C, 0xE9, 
    0xAB, 0x77, 0x77, 0x33, 0x04, 0x96, 0x8C, 0x3D, 0x9E, 0x3F, 0xDA, 0xB4, 0x38, 0x0E, 0x8A, 0x14, 
    0x86, 0x1C, 0x0A, 0x6C, 0xC6, 0x3F, 0xB2, 0x90, 0x62, 0x84, 0xCF, 0x80, 0xA7, 0x1F, 0x24, 0x10, 
    0xF5, 0x7A, 0x88, 0xA5, 0x13, 0xD2, 0x43, 0x88, 0x2A, 0x9D, 0x7C, 0x2D, 0x46, 0xE4, 0xAE, 0xE8, 
    0x88, 0xC6, 0x58, 0x83, 0x80, 0x4F, 0xF3, 0xEE, 0x35, 0x32, 0xF4, 0xDA, 0x88, 0xD2, 0xB8, 0x85, 
    0x70, 0x74, 0x3E, 0x14, 0x23, 0x26, 0x6E, 0x33, 0x99, 0x4B, 0x0B, 0xED, 0xCA, 0x0F, 0x75, 0x9E, 
    0xC8, 0xF4, 0x48, 0x7D, 0x3B, 0xD4, 0xD9, 0xE9, 0xB3, 0x50, 0xB7, 0x67, 0x01, 0x9A, 0xCA, 0xCC, 
    0x23, 0x50, 0x27, 0x59, 0x01, 0x98, 0x33, 0x7D, 0xB2, 0x87, 0x8B, 0xC7, 0x32, 0x34, 0x11, 0xF6, 
    0x10, 0x28, 0x8E, 0x2B, 0x1B, 0xD9, 0x75, 0x24, 0x4F, 0x38, 0x24, 0xE6
};

__align(4) const U8 lzma_test_data_decompressed[] = { 
    0x05, 0xD7, 0x05, 0xD7, 
    0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xDA, 0x33, 0x61, 0xF4, 0x61, 0x60, 0xE0, 
    0xFF, 0x00, 0x42, 0x20, 0x20, 0xC8, 0x0C, 0x24, 0xFE, 0xFF, 0xBF, 0xBE, 0x57, 0x27, 0x99, 0xC1, 
    0x40, 0xA3, 0x43, 0x4B, 0x45, 0xC1, 0x99, 0xD1, 0x48, 0x64, 0x81, 0x23, 0x83, 0xB0, 0x48, 0x82, 
    0x23, 0xA3, 0xB0, 0x88, 0x82, 0x63, 0x93, 0xB9, 0x23, 0xA3, 0x14, 0x8B, 0x01, 0x06, 0x61, 0x24, 
    0xA2, 0xE0, 0xCC, 0xA4, 0xA5, 0xB2, 0xC2, 0x80, 0x83, 0x01, 0x00, 0xE5, 0xB2, 0x0F, 0xD3, 0x34, 
    0x01, 0x4A, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 
    0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 
    0x43, 0x01, 0x32, 0x14, 0x20, 0x41, 0x02, 0x13, 0x04, 0xA9, 0x55, 0x57, 0x57, 0xE9, 0x41, 0x86, 
    0x57, 0xA9, 0x41, 0x00, 0x13, 0x14, 0x60, 0x41, 0x00, 0x17, 0x14, 0x20, 0x41, 0x00, 0x1B, 0x54, 
    0xA8, 0x55, 0x04, 0x17, 0x56, 0x29, 0x43, 0x01, 0x32, 0x24, 0xA0, 0x42, 0x82, 0x0A, 0x83, 0x00, 
    0x00, 0x34, 0x01, 0x48, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 
    0x24, 0x20, 0x43, 0x01, 0x32, 0x14, 0x20, 0x41, 0x02, 0x13, 0x04, 0xA9, 0x55, 0x57, 0x57, 0xE9, 
    0x41, 0x86, 0x57, 0x69, 0x41, 0x01, 0x13, 0x14, 0xE0, 0x41, 0x95, 0x57, 0x69, 0xD5, 0xD5, 0x55, 
    0x4A, 0x90, 0xC0, 0x04, 0x05, 0xC8, 0x50, 0x80, 0x0C, 0x09, 0xA8, 0x90, 0xA0, 0xC2, 0x20, 0x00, 
    0x00, 0x34, 0x01, 0x4C, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 
    0x24, 0x20, 0x43, 0x01, 0x32, 0x14, 0xA0, 0x41, 0x00, 0x13, 0x14, 0x60, 0x41, 0x01, 0x13, 0x14, 
    0x20, 0x41, 0x82, 0x37, 0x41, 0x01, 0x12, 0x24, 0x78, 0x13, 0x94, 0xA8, 0x55, 0xD7, 0x04, 0x15, 
    0x6A, 0x15, 0xC1, 0x85, 0x55, 0x6A, 0x10, 0xC0, 0x04, 0x05, 0xC8, 0x50, 0x80, 0x0C, 0x09, 0xA8, 
    0x90, 0xA0, 0xC2, 0x20, 0x00, 0x34, 0x01, 0x48, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 
    0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 0x32, 0x14, 0x20, 0x41, 0x89, 0xFF, 0x55, 0x4A, 
    0x10, 0xC0, 0x06, 0x25, 0x6A, 0xD5, 0x3F, 0x41, 0x90, 0x5A, 0x75, 0x75, 0x95, 0x1E, 0x54, 0x79, 
    0x95, 0x56, 0x5D, 0x5D, 0xA5, 0x04, 0x09, 0x4C, 0x50, 0x80, 0x0C, 0x05, 0xC8, 0x90, 0x80, 0x0A, 
    0x09, 0x2A, 0x0C, 0x02, 0x00, 0x34, 0x01, 0x48, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 
    0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 0x32, 0x14, 0x20, 0x41, 0x02, 0x13, 0x54, 0xA9, 
    0x55, 0x57, 0x57, 0x69, 0xD5, 0x07, 0x25, 0x6A, 0xD5, 0x3F, 0x41, 0x9F, 0x5A, 0x75, 0x75, 0x95, 
    0x56, 0x5D, 0x5D, 0xA5, 0x04, 0x09, 0x4C, 0x50, 0x80, 0x0C, 0x05, 0xC8, 0x90, 0x80, 0x0A, 0x09, 
    0x2A, 0x0C, 0x02, 0x00, 0x00, 0x78, 0xDA, 0x33, 0x61, 0xF4, 0x61, 0x60, 0xE0, 0xFF, 0x00, 0x42, 
    0x20, 0x20, 0xC8, 0x0C, 0x24, 0xFE, 0xFF, 0xBF, 0xBE, 0x57, 0x27, 0x99, 0xC1, 0x40, 0xA3, 0x43, 
    0x4B, 0x45, 0xC1, 0x99, 0xD1, 0x28, 0x64, 0x45, 0x28, 0x8B, 0x78, 0xD8, 0x4B, 0xC7, 0xB6, 0xF0, 
    0x95, 0x8E, 0x0C, 0xC2, 0x22, 0x0B, 0x40, 0x44, 0x82, 0x23, 0x83, 0x38, 0x12, 0x01, 0x52, 0xA6, 
    0xB2, 0xC0, 0xA9, 0x89, 0xAB, 0x19, 0xA8, 0x1F, 0x00, 0x5C, 0xD3, 0x13, 0x6A, 0x34, 0x01, 0x48, 
    0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 
    0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 
    0x32, 0x14, 0x20, 0x41, 0x02, 0x13, 0xF4, 0xA9, 0x55, 0x57, 0x57, 0x69, 0xD5, 0xD5, 0x55, 0x4A, 
    0x90, 0xC0, 0x04, 0x7D, 0x6A, 0xD5, 0xD5, 0x55, 0x5A, 0x75, 0x75, 0x95, 0x12, 0x24, 0x30, 0x41, 
    0x01, 0x32, 0x14, 0x20, 0x43, 0x02, 0x2A, 0x24, 0xA8, 0x30, 0x08, 0x00, 0x00, 0x34, 0x01, 0x48, 
    0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 
    0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 
    0x32, 0x14, 0x20, 0x41, 0x02, 0x13, 0xF4, 0xA9, 0x55, 0x57, 0x57, 0x69, 0xD5, 0xD5, 0x55, 0x4A, 
    0x50, 0xE2, 0x7F, 0x95, 0x1E, 0x54, 0x79, 0x95, 0x56, 0x5D, 0x5D, 0xA5, 0x04, 0x09, 0x4C, 0x50, 
    0x80, 0x0C, 0x05, 0xC8, 0x90, 0x80, 0x0A, 0x09, 0x2A, 0x0C, 0x02, 0x00, 0x00, 0x34, 0x01, 0x44, 
    0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 
    0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 
    0x32, 0xA4, 0xAE, 0xD5, 0xD5, 0x5F, 0x69, 0x7D, 0x5D, 0x5D, 0xDA, 0x5D, 0x57, 0x97, 0x56, 0xD7, 
    0xD5, 0xA5, 0xD5, 0x75, 0x75, 0x69, 0x75, 0x5D, 0x5D, 0x5A, 0x5D, 0xFD, 0x95, 0x32, 0x14, 0x20, 
    0x43, 0x02, 0x2A, 0x24, 0xA8, 0x30, 0x08, 0x00, 0x00, 0x34, 0x01, 0x48, 0x00, 0x00, 0x0F, 0xF0, 
    0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 
    0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 0x32, 0x54, 0xA8, 0xD5, 
    0x04, 0x9D, 0x5E, 0x69, 0x7D, 0xD5, 0x57, 0xDA, 0x5D, 0xDD, 0x95, 0x56, 0x13, 0x94, 0x78, 0xA5, 
    0xD5, 0x04, 0x25, 0x5E, 0x69, 0x35, 0x41, 0x89, 0x57, 0x5A, 0x4D, 0x50, 0xE1, 0x95, 0x32, 0x14, 
    0x20, 0x43, 0x02, 0x2A, 0x24, 0xA8, 0x30, 0x08, 0x00, 0x34, 0x01, 0x48, 0x00, 0x00, 0x0F, 0xF0, 
    0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 
    0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 0x32, 0x34, 0xAA, 0xD5, 
    0xD5, 0x5F, 0x69, 0x7D, 0x5D, 0x5D, 0xDA, 0x5D, 0x10, 0xE2, 0xA5, 0xD5, 0x04, 0x71, 0x5E, 0x69, 
    0x75, 0xD5, 0x55, 0x5A, 0x5D, 0x4D, 0xD0, 0xA1, 0x56, 0x17, 0xC1, 0x83, 0xA5, 0x0C, 0x05, 0xC8, 
    0x90, 0x80, 0x0A, 0x09, 0x2A, 0x0C, 0x02, 0x00, 0x00, 0x34, 0x01, 0x46, 0x00, 0x00, 0x0F, 0xF0, 
    0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 
    0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 0x32, 0x34, 0xAA, 0xD5, 
    0xD5, 0x5F, 0x69, 0x7D, 0x5D, 0x5D, 0xDA, 0x5D, 0xD0, 0xE5, 0xA5, 0xD5, 0x55, 0x5F, 0x69, 0x75, 
    0x41, 0xA2, 0x97, 0x56, 0xD7, 0xD5, 0xA5, 0xD5, 0xD5, 0x5F, 0x29, 0x43, 0x01, 0x32, 0x24, 0xA0, 
    0x42, 0x82, 0x0A, 0x83, 0x00, 0x00, 0x00, 0x34, 0x01, 0x46, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 
    0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 
    0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 0x32, 0x54, 0xA8, 0xD5, 0x04, 0x1D, 
    0x5F, 0x69, 0x7D, 0xD5, 0x57, 0xDA, 0x5D, 0xDD, 0x95, 0x56, 0x57, 0x77, 0xA5, 0xD5, 0x75, 0x5D, 
    0x69, 0x75, 0x11, 0x7C, 0x58, 0x5A, 0x4D, 0x50, 0xE1, 0x95, 0x32, 0x14, 0x20, 0x43, 0x02, 0x2A, 
    0x24, 0xA8, 0x30, 0x08, 0x00, 0x34, 0x01, 0x46, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 
    0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 0x32, 0x84, 0xA9, 0xD5, 0xD5, 0x7F, 0x69, 0x7D, 
    0x35, 0x41, 0xA3, 0xDA, 0x5D, 0xFF, 0x95, 0x56, 0xD7, 0xD5, 0xA5, 0xD5, 0x05, 0x89, 0x5E, 0x5A, 
    0x5D, 0x57, 0x97, 0x56, 0x57, 0x7F, 0xA5, 0x0C, 0x05, 0xC8, 0x90, 0x80, 0x0A, 0x09, 0x2A, 0x0C, 
    0x02, 0x00, 0x00, 0x34, 0x01, 0x44, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 
    0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 0x32, 0x64, 0xAA, 0xD5, 0xD5, 0x5F, 0x69, 0x7D, 0x5D, 0x5D, 
    0xDA, 0x5D, 0x17, 0xD4, 0xAB, 0xD5, 0xF5, 0x5F, 0x69, 0x75, 0x5D, 0x5D, 0x5A, 0x5D, 0x57, 0x97, 
    0x56, 0x57, 0x7F, 0xA5, 0x0C, 0x05, 0xC8, 0x90, 0x80, 0x0A, 0x09, 0x2A, 0x0C, 0x02, 0x00, 0x34, 
    0x01, 0x48, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 
    0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 
    0x43, 0x01, 0x32, 0x74, 0xA8, 0xD5, 0x45, 0xF0, 0x61, 0x69, 0x7D, 0x41, 0x88, 0x97, 0x76, 0x13, 
    0x94, 0x78, 0xA5, 0xD5, 0x04, 0xC9, 0x5E, 0x69, 0x75, 0xD5, 0x55, 0x5A, 0x5D, 0x75, 0x95, 0x56, 
    0x57, 0x5D, 0xA5, 0x0C, 0x05, 0xC8, 0x90, 0x80, 0x0A, 0x09, 0x2A, 0x0C, 0x02, 0x00, 0x00, 0x34, 
    0x01, 0x44, 0x00, 0x00, 0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 
    0x00, 0x00, 0x00, 0xFF, 0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 
    0x43, 0x01, 0x32, 0xA4, 0xAE, 0xD5, 0xD5, 0x5F, 0x69, 0x7D, 0x5D, 0x5D, 0xDA, 0x5D, 0x57, 0x97, 
    0x56, 0x57, 0x7F, 0xA5, 0xD5, 0x75, 0x75, 0x69, 0x75, 0x5D, 0x5D, 0x5A, 0x5D, 0xFD, 0x95, 0x32, 
    0x14, 0x20, 0x43, 0x02, 0x2A, 0x24, 0xA8, 0x30, 0x08, 0x00, 0x00, 0x34, 0x01, 0x44, 0x00, 0x00, 
    0x0F, 0xF0, 0x00, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x00, 0xFF, 
    0xFF, 0xD7, 0xBD, 0x2C, 0x63, 0x00, 0x30, 0x28, 0x88, 0x2A, 0x24, 0x20, 0x43, 0x01, 0x32, 0x14, 
    0xAC, 0xD5, 0xD5, 0x5F, 0x69, 0x7D, 0x5D, 0x5D, 0xDA, 0x5D, 0x57, 0x97, 0x56, 0x57, 0xFF, 0xA5, 
    0xD5, 0x05, 0x89, 0x5E, 0x5A, 0x5D, 0x57, 0x97, 0x56, 0x57, 0x7F, 0xA5, 0x0C, 0x05, 0xC8, 0x90, 
    0x80, 0x0A, 0x09, 0x2A, 0x0C, 0x02, 0x00
};


void lzmaUnitTest()
{
    U8 * compressPtr = (U8 *)lzma_test_data_compressed;
    U8 * decompressedPtr = (U8 *)lzma_test_data_decompressed_buffer;
    U8 * noCompressPtr = (U8 *)lzma_test_data_decompressed;
    int compareResult = 0;
    compressPtr = compressPtr + 4;
    noCompressPtr = noCompressPtr +4;
    mmi_res_lzma_decompress(decompressedPtr,  1495 ,compressPtr, 604);
    compareResult = memcmp(noCompressPtr, decompressedPtr, 1495);
    ASSERT(compareResult == 0);
}
// ------------------------------------- Unit Test End-----------------------------------------------
#endif // __MMI_RESOURCE_UT_UNCOMPRESSED_IMAGE_SUPPORT__
#endif // (__MMI_RESOURCE_STR_LZMA_COMPRESS__) || defined(__MMI_IMAGE_GROUP_COMPRESS__)
